{include file="header"}
<div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body" style="padding: 15px;">
          <div style="padding: 10px; margin-top: 10px;background-color: #f6f6f6; color: #FF5722;"> 
            创建字段信息
          </div>
        <form class="layui-form">
          
          <input type="hidden" name="model" value="{$c.name}">
          <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">容器宽度</label>
                <div class="layui-input-block">
                 <select name="c[md]" lay-verify="required" >
                        <option value="1">1/12</option>
                        <option value="2">2/12</option>
                        <option value="3">3/12</option>
                        <option value="4">4/12</option>
                        <option value="5">5/12</option>
                        <option value="6" selected="选择">6/12</option>
                        <option value="7">7/12</option>
                        <option value="8">8/12</option>
                        <option value="9">9/12</option>
                        <option value="10">10/12</option>
                        <option value="11">11/12</option>
                        <option value="12">12/12</option>
                    </select>
                </div>
              </div>
            </div>
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">命名标题</label>
                <div class="layui-input-block">
                  <input type="text" name="c[title]" lay-verify="required" autocomplete="off" placeholder="例如:附件" class="layui-input">
                </div>
              </div>
            </div>
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">默认值</label>
                <div class="layui-input-block">
                  <input type="text" name="c[value]" autocomplete="off" placeholder="默认值 可空" class="layui-input">
                </div>
              </div>
            </div>
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">是否必填</label>
                <div class="layui-input-block">
                   <select name="c[required]">
                        <option value="0">默认否</option>
                        <option value="required">必填</option>
                    </select>
                </div>
              </div>
            </div>
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">后台显示</label>
                <div class="layui-input-block">
                   <select name="c[admin]">
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </div>
              </div>
            </div>
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">前台显示</label>
                <div class="layui-input-block">
                   <select name="c[index]">
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </div>
              </div>
            </div>
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">类型</label>
                <div class="layui-input-block">
                   <select lay-filter="filter" name="c[type]" lay-verify="required" >
                        <option value="输入框">输入框</option>
                        <option value="多选">多选</option>
                        <option value="选择框">选择框</option>
                        <option value="单选框">单选框</option>
                        <option value="密码框">密码框</option>
                        <option value="文本域">文本域</option>
                        <option value="附件">附件</option>
                        <option value="时间">时间选择</option>
                        <option value="颜色">颜色</option>
                    </select>
                </div>
              </div>
            </div>
            
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">字段</label>
                <div class="layui-input-block">
                   <input type="text" name="c[zhiduan]" autocomplete="off" lay-verify="required" placeholder="创建的字段 必填写" class="layui-input">
                </div>
              </div>
            </div>
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">字段定义值</label>
                <div class="layui-input-block">
                   <input type="text" name="c[definition]" autocomplete="off" placeholder="可空" class="layui-input">
                </div>
              </div>
            </div>
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">字段类型</label>
                <div class="layui-input-block">
                   <input type="text" name="c[sqltype]" autocomplete="off" lay-verify="required" value="VARCHAR(1000)" placeholder="例如: VARCHAR(1000)" class="layui-input">
                </div>
              </div>
            </div>
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">自定义</label>
                <div class="layui-input-block">
                   <input type="text" name="c[dingyi]" autocomplete="off" value="1,2" placeholder="自定义显示配置" class="layui-input">
                </div>
              </div>
            </div>
            <script>
            layui.use(['form','layer','table'], function(){
               var form = layui.form;
               var $ = layui.jquery;
               form.on('select(filter)', function(data){
            	   var company = data.value;
            	   $(".biaotipz").html(company+"配置");
            	   if(company=='多选'){
            	       $(".text_pz").attr("lay-verify","required");
            	       $(".xiansyc").show();
            	   }else if(company=='选择框'){
            	       $(".text_pz").attr("lay-verify","required");
            	       $(".xiansyc").show();
            	   }else if(company=='单选框'){
            	       $(".text_pz").attr("lay-verify","required");
            	       $(".xiansyc").show();
            	   }else{
            	       $(".text_pz").val("");
            	       $(".text_pz").attr("lay-verify","");
            	       $(".xiansyc").hide();
            	   }
            	 });      
             });
            </script>   
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <button class="layui-btn" lay-submit lay-filter="formapi">创建字段信息</button>
              </div>
            </div>
            <div class="layui-col-md12 xiansyc" style="display: none;">
              <div class="layui-form-item">
                <label class="layui-form-label biaotipz">多选配置</label>
                <div class="layui-input-block">
                   <textarea  lay-verify="" placeholder="一行一个数据格式【值,显示内容   换行  值,显示内容】 例如: 1,开启    需要换行   0,关闭" name="c[options]" class="layui-textarea text_pz"></textarea>
                </div>
              </div>
            </div>
            </form>
            <script>
            layui.use(['jquery', 'form'],
            function() {
                var form = layui.form,
                jq = layui.jquery;
                form.on('submit(formapi)',
                function(data) {
                    loading = layer.load(2, {
                        shade: [0.2, '#000']
                    });
                    var param = data.field;
                    jq.post('{:url('admin/api/model_config_api')}', param,
                      function(data) {
                        layer.close(loading);
                        layer.msg('添加成功', {icon: 1, time: 1000}, function(){
                            if($(".text_config").val()){
                                $(".text_config").val($(".text_config").val()+'\n'+data.msg);
                            }else{
                                $(".text_config").val(data.msg);
                            }
                        });
                      });
                    return false;
                });
            })
            </script>
             <hr>
	      <!-- 创建模型 -->
		  <form class="layui-form form1" url="{:url('admin/api/model_config')}" t_url="javascript:location.reload();">
		  <input type="hidden" name="id" value="{$c.id}">
          <input type="hidden" name="model" value="{$c.name}">
          <div style="padding: 10px; margin-top: 10px;background-color: #f6f6f6; color: #FF5722;"> 
            配置 信息一行一个 保存即可生效 配置信息填写错误会一直转圈请重新打开页面即可重新配置
          </div>
          <textarea  placeholder="配置信息" name="config" class="layui-textarea text_config" style="height: 300px;">{$c.config}</textarea>
          
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">命名</label>
                <div class="layui-input-block">
                   <input type="text" name="title" autocomplete="off" lay-verify="required" value="{$c.title}" placeholder="命名" class="layui-input">
                </div>
              </div>
            </div>
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">前台显示</label>
                <div class="layui-input-block">
                   <select lay-filter="filter" name="open" lay-verify="required" >
                       <option value="1" {if $c.open == 1}selected="选择"{/if}>是</option>
                        <option value="0" {if $c.open == 0}selected="选择"{/if}>否</option>
                    </select>
                </div>
              </div>
            </div>
            <div class="layui-col-md8">
              <div class="layui-form-item">
                <label class="layui-form-label">自定义显示</label>
                <div class="layui-input-block">
                   <input type="text" name="open1" autocomplete="off" value="{$c.open1}" placeholder="自定义配置显示 不懂可空 字段 open1" class="layui-input">
                </div>
              </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">模型关键字</label>
                <div class="layui-input-block">
                    <input type="text" name="keywords" value="{$c.keywords}" autocomplete="off" placeholder="请输入seo关键字" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">模型描述</label>
                <div class="layui-input-block">
                    <textarea name="description" placeholder="seo描述" class="layui-textarea">{$c.description}</textarea>
                </div>
            </div>
            
          <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
              <div class="layui-footer" style="left: 0;">
                <button class="layui-btn" lay-submit="" lay-filter="cms1">立即提交</button>
              </div>
            </div>
          </div>
        </form>
  
      <!-- {foreach name=":json_model($c.config)" item="v" key="k"}-->
      <!--      {:json_model_v($v,'md')}-->
      <!--{/foreach}-->
        
        <div style="padding: 10px; margin-top: 10px;background-color: #f6f6f6; color: #FF5722;"> 
            模型字段
        </div>
        <div  style="overflow: auto;margin-bottom: 50px;">
            <table class="layui-table" style="min-width: 1000px;">
                <thead>
                    <tr>
                        <th>字段</th>
                        <th>类型</th>   
                        <th>描述</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {volist name="$sql" id="vo"}
                    <!--内容-->
                    <tr>
                        <td>{$vo.COLUMN_NAME} </td>
                        <td>{$vo.COLUMN_TYPE}</td>
                        <td>{$vo.COLUMN_COMMENT}</td>
                        <td class="td-manage">
                            <a class="layui-btn layui-btn-sm layui-btn-danger del_t" url="{:url('admin/api/modelzd')}?m={$c.name}&id={$vo.COLUMN_NAME}" name="确定要删除这个字段吗？删除后不可恢复数据！添加字段在配置信息里面重新添加"><i class="layui-icon"></i>删除</a>
                        </td>
                    </tr>
                    {/volist}
                </tbody>
            </table>
        </div>
      </div>
    </div>
  </div>
  {include file="footer"}